﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

using System.Globalization;
using System.IO;
using System.Reflection;

namespace UIKit
{
    /// <summary>
    /// This is the base bundle logic that will now look at WPF/Silverlight class/usercontrol
    /// loading
    /// </summary>
    public partial class NSBundle
    {
        #region instance methods

        #region paths code

        public string builtInPlugInsPath() { throw new NotImplementedException(); }
        public string bundleIdentifier() { throw new NotImplementedException(); }
        public string bundlePath() { throw new NotImplementedException(); }
        public string privateFrameworksPath()  { throw new NotImplementedException(); }
        public string resourcePath()  { throw new NotImplementedException(); }
        public string sharedFrameworksPath()  { throw new NotImplementedException(); }
        public string sharedSupportPath()  { throw new NotImplementedException(); }
        public string executablePath()  { throw new NotImplementedException(); }

        #endregion

        #region loading lifecycle code

        public Type classNamed(string className) { return Type.GetType(className); }
        public int[] executableArchitectures() { return new int[] { }; }
        public Dictionary<object, object> infoDictionary() { throw new NotImplementedException(); }
       

        /// <summary>
        /// possibly load an assembly based on the path, 
        /// if it were a xap, do the web request etc for it?
        /// </summary>
        /// <param name="fullPath"></param>
        /// <returns></returns>
        public object initWithPath(string fullPath)
        {
            throw new NotImplementedException();
        }

        public bool isLoaded() { 
            return false; 
        }

        public bool load()
        {
            throw new NotImplementedException();
        }

        public bool loadAndReturnError(out Exception error)
        {
            throw new NotImplementedException();
            try
            {
                //do the loading code here
            }
            catch (FileNotFoundException ex)
            {
                error = ex;
            }
            catch (FileLoadException ex)
            {
                error = ex;
            }
        }

        public bool unload()
        {
            throw new NotImplementedException();
        }

        public bool preflightAndReturnError(out Exception error)
        {
            throw new NotImplementedException();
        }

        public Type principalClass()
        {
            throw new NotImplementedException();
        }
        #endregion

        #region localization code
        /// <summary>
        /// LG: Replaced Return type with CultureInfo, was string.
        /// </summary>
        /// <returns></returns>
        public CultureInfo developmentLocalization() { return new CultureInfo("en-GB"); }

        public string[] localizations()
        {
            throw new NotImplementedException();
        }
        public Dictionary<string, string> localizedInfoDictionary()
        {
            throw new NotImplementedException();
        }
        public string localizedStringForKey(string key, string value, string tableName)
        {
            throw new NotImplementedException();
        }
        public object objectForInfoDictionaryKey(string key)
        {
            throw new NotImplementedException();
        }
        public string pathForAuxiliaryExecutable(string executableName)
        {
            throw new NotImplementedException();
        }
        public string pathForResource(string name, string extension)
        {
            throw new NotImplementedException();
        }
        public string pathForResource(string name, string extension, string subPath)
        {
            throw new NotImplementedException();
        }
        public string pathForResource(string name, string extension, string subPath, string localizationName)
        {
            throw new NotImplementedException();
        }
        public string[] pathsForResourcesOfType(string extension, string subPath)
        {
            throw new NotImplementedException();
        }
        public string[] pathsForResourcesOfType(string extension, string subPath, string localizationName)
        {
            throw new NotImplementedException();
        }
        public string[] preferredLocalizations()
        {
            throw new NotImplementedException();
        }


        #endregion

        #endregion

        #region class methods

        public static NSBundle[] allBundles() { throw new NotImplementedException(); }
        public static NSBundle[] allFrameworks() { throw new NotImplementedException(); }
        public static NSBundle bundleForClass(Type aClass) { throw new NotImplementedException(); }
        public static NSBundle bundleWithIdentifier(string identifier) { throw new NotImplementedException(); }
        public static NSBundle bundleWithPath(string fullPath) { throw new NotImplementedException(); }
        
        private static NSBundle _mainBundle = null;
        public static NSBundle mainBundle() {
            if (_mainBundle == null) {
                _mainBundle = new NSBundle();
                Assembly thisAssembly = Assembly.GetExecutingAssembly();
                _mainBundle.setBundleIdentifier(thisAssembly.FullName);
                // _mainBundle.load(); // semantically we haven't asked for this to be loaded.
            }

            return _mainBundle;
        }
        //public static string pathForResource(string name, string extension, string bundlePath) { throw new NotImplementedException(); }
        //public static string[] pathsForResourcesOfType(string extension, string bundlePath) { throw new NotImplementedException(); }
        public static string[] preferredLocalizationsFromArray(string[] localizationsArray) { throw new NotImplementedException(); }
        public static string preferredLocalizationsFromArray(string[] localizationsArray, string[] preferencesArray) { throw new NotImplementedException(); }

        #endregion

        #region constants

        #endregion


        #region non-UIKit code

        private string _bundleIdentifier = String.Empty;
        public void setBundleIdentifier(string identifier) {
            _bundleIdentifier = identifier;
        }

        #endregion
    }
}
